﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESpace;

namespace ESpace_Project
{
    public partial class FormStream : Form
    {
        
        Graphics gr;

        public FormStream()
        {
            InitializeComponent();
            gr = Graphics.FromHwnd(this.Handle); 
        }

        private void button1_Click(object sender, EventArgs e)
        {
            EStream strm = new EStream(Application.StartupPath + "\\StreamData\\test.test");
            strm.OpenSave();
            strm.SaveStr("Тест");
            strm.SaveInt(25);
            strm.SaveDouble(123.123);
            byte[] buf = Encoding.Unicode.GetBytes("Строка для буфера");
            strm.SaveBuf(buf);
            strm.SaveStr("Тест");
            strm.SaveInt(25);
            strm.SaveDouble(123.123);
            strm.SaveBmp(new Bitmap(Application.StartupPath + "\\StreamData\\1.jpg"));
            strm.SaveDate(DateTime.Now);
            strm.SaveStr("Тест");
            strm.SaveInt(25);
            strm.SaveDouble(123.123);
            strm.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            lb.Items.Clear();

            EStream strm = new EStream(Application.StartupPath + "\\StreamData\\test.test");
            strm.OpenLoad();
            lb.Items.Add(strm.LoadStr());
            lb.Items.Add(strm.LoadInt());
            lb.Items.Add(strm.LoadDouble());
            lb.Items.Add(Encoding.Unicode.GetString(strm.LoadBuf()));
            lb.Items.Add(strm.LoadStr());
            lb.Items.Add(strm.LoadInt());
            lb.Items.Add(strm.LoadDouble());
            gr.DrawImage(strm.LoadBmp(), 200, 0);
            lb.Items.Add(strm.LoadDate().ToString());
            lb.Items.Add(strm.LoadStr());
            lb.Items.Add(strm.LoadInt());
            lb.Items.Add(strm.LoadDouble());

            strm.Close();
        }
    }
}
